/*
 * KeySequence.h
 *
 *  Created on: 2010-9-9
 *      Author: wenjian
 */

#ifndef KEYSEQUENCE_H_
#define KEYSEQUENCE_H_
#include "../commons.h"
using namespace std;
namespace Ed {

  /**
   * 键序列
   */
  class KeySequence {
    public:
      enum SequenceMatch {
          NoMatch,          //不匹配
          PartialMatch,     //部分匹配, 即包含
          ExactMatch        //精确匹配, 完成相等
      };
    public:
      KeySequence();
      KeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0);
      KeySequence(const KeySequence &ks);

      virtual ~KeySequence();

      /**
       * 向序列增加键
       */
      void add(int key);

      /**
       * 加入另一个序列中的键
       */
      void add(const KeySequence &ks);

      unsigned int size() const;

      bool empty() const;

//      /**
//       * 检查两个序列匹配情况, serial指定是否顺序包含
//       */
//      SequenceMatch matches(const KeySequence &seq, bool serial=false) const;

      /**
       * 返回指定位置上的键
       */
      int at(int index){
        return sequence.at(index);
      }

      /**
       * 测试键序列
       */
      bool test(int key) const;

      int operator[](unsigned int i) const;

      bool operator==(const KeySequence &other) const;

      inline bool operator!= (const KeySequence &other) const
      { return !(*this == other); }


    private:
      vector<int> sequence;
  };

}

#endif /* KEYSEQUENCE_H_ */
